<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改稿件管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-paper-edit" th:object="${workPaper}">
            <input name="paperId" th:field="*{paperId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">稿件名称：</label>
                <div class="col-sm-8">
                    <input name="paperName" th:field="*{paperName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户名称：</label>
                <div class="col-sm-8">
                    <input name="customerName" th:field="*{customerName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户所属公司：</label>
                <div class="col-sm-8">
                    <input name="companyName" th:field="*{companyName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">媒体名称：</label>
                <div class="col-sm-8">
                    <input name="mediaName" th:field="*{mediaName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">平台：</label>
                <div class="col-sm-8">
                    <input name="platform" th:field="*{platform}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">媒介：</label>
                <div class="col-sm-8">
                    <input name="mediaCreate" th:field="*{mediaCreate}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">刊登链接：</label>
                <div class="col-sm-8">
                    <input name="publishLink" th:field="*{publishLink}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">刊登时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="publishDate" th:value="${#dates.format(workPaper.publishDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">稿件费：</label>
                <div class="col-sm-8">
                    <input name="paperPrice" th:field="*{paperPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">刷量费：</label>
                <div class="col-sm-8">
                    <input name="flowPrice" th:field="*{flowPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">成本：</label>
                <div class="col-sm-8">
                    <input name="cost" th:field="*{cost}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">实际成本：</label>
                <div class="col-sm-8">
                    <input name="actualCost" th:field="*{actualCost}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">单价：</label>
                <div class="col-sm-8">
                    <input name="price" th:field="*{price}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">字数：</label>
                <div class="col-sm-8">
                    <input name="words" th:field="*{words}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">实际总价：</label>
                <div class="col-sm-8">
                    <input name="actualPrice" th:field="*{actualPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">销账时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="offAccountDate" th:value="${#dates.format(workPaper.offAccountDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">提成：</label>
                <div class="col-sm-8">
                    <input name="commision" th:field="*{commision}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">提成时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="commisionDate" th:value="${#dates.format(workPaper.commisionDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">刷量备注：</label>
                <div class="col-sm-8">
                    <input name="flowRemark" th:field="*{flowRemark}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">原始链接：</label>
                <div class="col-sm-8">
                    <input name="originalLink" th:field="*{originalLink}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上传稿件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="uploadFile" th:field="*{uploadFile}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="uploadFile" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">回款周期：</label>
                <div class="col-sm-8">
                    <input name="paybackPeriod" th:field="*{paybackPeriod}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "work/paper";
        $("#form-paper-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-paper-edit').serialize());
            }
        }

        $("input[name='publishDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='offAccountDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='commisionDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>